<div class="row">
	<div class="col-md-12">
		<div class="box box-primary">
			<form id="access-add-form" method="post">
				<div class="box-header with-border">
					<h3 class="box-title">访问请求添加</h3>
				</div>
				<div class="box-body">
					<div class="form-group">
						<label for="exampleInput" id="systemNameLabel">系统名</label>
						<input type="text" class="form-control" name="systemName" id="systemName" placeholder="输入系统名...">
					</div>
					<div class="form-group">
						<label for="exampleInput" id="fieldCodeLabel">系统三字码</label>
						<input type="text" class="form-control" name="systemCode" id="systemCode" placeholder="输入系统三字码值...">
					</div>
					<div class="form-group">
						<label for="exampleInput" id="envTypeLabel">环境类型</label>
						<select id="usertype" name="envType" class="selectpicker show-tick form-control" data-live-search="false">
                                <option value="SST">SST</option>
                                <option value="SIT">SIT</option>
                                <option value="PRD">PRD</option>
                        </select>
					</div>
					<div class="form-group">
						<label for="exampleInput">地址名</label>
						<input type="text" class="form-control" name="name" id="name" placeholder="输入地址名...">
					</div>
					
					<div class="form-group">
						<label for="exampleInput" id="urlLabel">请求的Url</label>
						<input type="text" class="form-control" name="url" id="name" placeholder="输入请求的Url...">
					</div>
				</div>
				<div class="box-footer">
	                <button type="button" class="btn btn-default"  data-dismiss="modal">取消</button>
	                <button id="access_data_add" type="button"  data-dismiss="modal" class="btn btn-info pull-right">添加</button>
              </div>
			</form>
		</div>
	</div>
</div>


<script type="text/javascript">
$(function(){
	$("#access_data_add").click(function(){
		var status = 1;
		$("span").remove(".errorSpan");
		$("br").remove(".errorBr");
		if ($("#systemName").val() == "") {
			$("#systemNameLabel").prepend('<span class="errorSpan" style="color:red">*系统名不能为空</span><br class="errorBr"/>');
			status = 0;
		}
		if ($("#envType").val() == "") {
			$("#envTypeLabel").prepend('<span class="errorSpan" style="color:red">*环境类型值不能为空</span><br class="errorBr"/>');
			status = 0;
		}
		if ($("#url").val() == "") {
			$("#urlLabel").prepend('<span class="errorSpan" style="color:red">*请求的Url不能为空</span><br class="errorBr"/>');
			status = 0;
		}
		if (status == 0) {
			return false;
		}
		ajaxPost();
	});

	function ajaxPost() {
		var options = {
	        url: '${ctx}/admin/access/save',
	        type: 'post',
	        dataType: 'text',
	        data: $("#access-add-form").serialize(),
	        success: function (data) {
	        	alertMsg("添加成功","success");
	        	reloadTable(list_ajax,"#access-time","#access-premise");
	        }
   		};
    $.ajax(options);
	}
});
</script>